package com.huqu.daoimpl;

import java.sql.Types;
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.huqu.basedao.QbDaoSupport;
import com.huqu.basedao.QbEntityMapper;
import com.huqu.basedao.QbSqlParam;
import com.huqu.dao.N200Dao;
import com.huqu.entities.N200;
import com.huqu.utils.ApplicationConstant;
import com.huqu.utils.SqlNames;


@Repository(value = ApplicationConstant.REPOSITORY_NAME_N200)
@Scope("prototype")
public class N200DaoImpl extends QbDaoSupport implements N200Dao {

	@Override
	public List<N200> ListOfTabN200(int nIDMUC, int nNUMBER, String vLANG) {
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.INTEGER, nIDMUC));
		listParams.add(new QbSqlParam(Types.INTEGER, nNUMBER));
		listParams.add(new QbSqlParam(Types.CHAR, vLANG));
		setQueenBListSqlParams(listParams);
		// set sql name
		setQueenBSqlName(SqlNames.LISTOFTABN200);
		// set row mapper
		setQueenBEntityMapper(new QbEntityMapper(N200.class));
		executeQueenBQuery();
		List<N200> listN200 = (List<N200>) getListReturn();
		return listN200;
	}

	@Override
	public int InsertTabN200(int nIDTHELOAI, int nIDMUC, String vTENTHELOAI_VI,
			String vTENTHELOAI_EN, String vHINHANH, int nNGUOITAO, int nDAXOA,
			int nKIEMDUYET, int nUUTIEN) {
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.INTEGER, nIDMUC));
		listParams.add(new QbSqlParam(Types.INTEGER, nIDTHELOAI));
		listParams.add(new QbSqlParam(Types.CHAR, vTENTHELOAI_VI));
		listParams.add(new QbSqlParam(Types.CHAR, vTENTHELOAI_EN));
		listParams.add(new QbSqlParam(Types.CHAR, vHINHANH));
		listParams.add(new QbSqlParam(Types.INTEGER, nNGUOITAO));
		listParams.add(new QbSqlParam(Types.INTEGER, nDAXOA));
		listParams.add(new QbSqlParam(Types.INTEGER, nKIEMDUYET));
		listParams.add(new QbSqlParam(Types.INTEGER, nUUTIEN));
		setQueenBListSqlParams(listParams);
		// set fuction
		setQbFunction(true);
		setQbFunctionReturnType(Types.INTEGER);
		setQueenBSqlName(SqlNames.INSERTTABN200);
		executeQueenBQuery();
		int re = Integer.parseInt(getObjectReturnFunction().toString());
		return re;
	}

}
